package com.capt_1;

import java.util.Random;

public class Equation {
    /**
     * 1，随机产生50个算式(加减乘除)
     * 2，随机在1-100
     * 3，控制台输出打印
     */

    public static void main(String[] args) {
        int leftNumber,rightNumber,result;
        char op = '+';
//        创建随机数对象
        Random random = new Random();
//        产生50个算式
        for (int i=0;i<50;i++){
            //     随机数   1-100
            leftNumber = random.nextInt(101);
            rightNumber = random.nextInt(101);
//            0-3随机数
            switch (random.nextInt(4)){
                case 0:
                    op = '+';
                    result = leftNumber + rightNumber;
                    break;
                case 1:
                    op = '-';
                    result = leftNumber - rightNumber;
                    break;
                case 2:
                    op = '*';
                    result = leftNumber * rightNumber;
                    break;
                case 3:
                    op = '/';
                    rightNumber = random.nextInt(101)+1;
                    result = leftNumber / rightNumber;
                    break;
            }
//            打印算式
            System.out.print("第"+(i+1)+"题:"+leftNumber +op + rightNumber+"=  ");
            if ((i+1)%5 == 0){
                System.out.println();
            }
        }

    }
}
